<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="/js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="/js/jquery-ui-1.8.21.custom.min.js"></script>
<script type="text/javascript" src="/js/jquery.leanModal.min.js"></script>
<link type="text/css" href="/css/start/jquery-ui-1.8.21.custom.css" rel="Stylesheet" />	
<link rel="stylesheet" href="/js/chosen/chosen.css" />
<title>Untitled Document</title>

<style>
.addstaff{
	display:none;
	}

.attn{
	background-color:#FF8080;	
}

</style>

<script>
	$(function() {

		$( "#date" ).datepicker({ dateFormat: "yy-mm-dd",firstDay: 1 });
		$( "#date_end" ).datepicker({ dateFormat: "yy-mm-dd",firstDay: 1 });
		$( "#pay_date" ).datepicker({ dateFormat: "yy-mm-dd",firstDay: 1 });
		
	});


</script>

<script language="javascript">
	function refocus(theid){
		
		if(theid !=""){
			document.getElementById(theid).focus();
			}
		}
	function ischeck(){
		var stf = $('#newRate').val();
		var type = $('#newRateType').val();
		var date = $('#date').val();

		if(stf.length >= 1 && type.length >= 1 && date.length >= 1 && $('#cb_app_ken').is(':checked') ){
			$("#add_record").prop('disabled', false);
		}else{
			$("#add_record").prop('disabled', true);
		}
	}
</script>
</head>

<body >
<form id = "form1" action="" method="post" enctype="multipart/form-data">
<div style="font-family:Arial, Helvetica, sans-serif" >


<?php 
  		$stDetail = new Model_DbTable_Roster_Stafflogindetail();
  		$st = new Model_DbTable_Roster_Staffinfo();
  		$stList = $stDetail->listStaffByNickName();
		$type = unserialize(PAYROLL_TYPE);
  		?>
<?php if(!$this->stfId){?>

Choose Staff
<select name="staff_name" data-placeholder="Staff Name" class="chzn-select" style="width:200px" >
      <option value=""></option>
      <?php foreach($stList as $k3 => $v3) {
      $stf = $st->getStaffinfo($v3['id']);
      	if($stf['is_wh'] != 1){
      	?>
      <option value="<?=$v3["id"]?>">
        <?=ucwords($v3["ni"])?>
        .
        <?=chr($v3["il"]+64)?> ( <?=ucwords(Model_EncryptHelper::getSslPassword($v3["n"]))?> )
        </option>
      <?php }}?>
    </select>
<br/><br/>
<input type = "submit" name = "submit" id = "submit" value = "Submit"></input>
<br/>
<br/>
<?php if(!empty($this->pending)){?>
<h3>Pending Case</h3>
<table border="1" cellspacing="0" cellpadding="5">
	<tr>
    	<th>Name</th>
  		<th>New Rate</th>
  		<th>New Rate Type</th>
  		<th>Current Rate</th>
  		<th>Current Rate Type</th>
  		<th>Apply Date</th>
    </tr>
	<?php foreach ($this->pending as $k2 => $v2){ 
		$stf = $st->getStaffinfo($v2['staff_id']);
  		 	$stfD = $stDetail->getDetail($v2['staff_id']);?>
  <tr>
  	<td><?php echo $stf['first_name']." ".$stf['last_name']."(".$stfD['ni'].")"?></td>
  	<td><?php echo $v2['new_rate']?></td>
  	<td><?php echo $type[$v2['new_rate_type']][1]?></td>
  	<td><?php echo $v2['old_rate']?></td>
  	<td><?php echo $type[$v2['old_rate_type']][1]?></td>
  	<td><?php echo $v2['apply_date']?></td>
  </tr>
	<?php }?>
</table>
<?php }?>
<?php if($this->check){
			echo "Add apply success";
			echo $this->message;
  		}?>
<?php if($this->message){?>
	<?php echo "Add apply success, detail as below<br/>"?>
	<?php echo $this->message;?>
<?php }?>

</div>

<?php }?>
<?php if($this->stfId){?>

<?php 
		$stf = $st->getStaffinfo($this->stfId);
		$stfD = $stDetail->getDetail($this->stfId);
  		$type = unserialize(PAYROLL_TYPE);
  		?>
<h2>Change Rate</h2>

<table border="1" cellspacing="0" cellpadding="5" width="500">
  <tr>
  	<td scope="col">Name</td>	
	<td scope="col"><?php echo $stf['first_name']." ".$stf['last_name']."(".$stfD['ni'].")"?></td>
  </tr>
  <tr>
	<td scope="col">Current Rate</td>	
	<td scope="col"><?php echo $stf['old_rate']?></td>		
  </tr>
  <tr>
	<td scope="col">Current Rate Type</td>	
	<td scope="col"><?php echo $type[$stf['id_package']][1]?></td>		
  </tr>
  <tr>
	<td scope="col">New Rate*</td>	
	<td scope="col"><input type = "text" name = "newRate" id = "newRate" onchange = "ischeck()" value="<?php echo $this->applyRate;?>" /></td>		
  </tr>	
   <tr>
	<td scope="col">New Rate Type*</td>	
	<td scope="col"><select name = "newRateType" id = "newRateType">
						<?php foreach ($type as $k => $v){?>
						<option value = "<?php echo $k;?>">
							<?php echo $v[1];?>
						</option>
						<?php }?>
					</select></td>		
  </tr>	
  <tr>
	<td scope="col">Effective Date*</td>	
	<td scope="col"><input type = "text" name = "date" id = "date" onchange = "ischeck()"></input></td>		
  </tr>
  <tr>
	<td scope="col">Comment</td>	
	<td scope="col"><textarea name = "comment" id = "comment" style = "width:200px;height:80px;padding:5px;"></textarea></td>		
  </tr>
  <tr>
	<td scope="col">Review Document</td>	
	<td scope="col"><input type = "file" name = "file" ></input></td>		
  </tr>
  <tr>
    <td colspan="2" scope="col"><input type="checkbox" name="cb_app_ken" id="cb_app_ken" onchange = "ischeck()" />
      I acknowledge the rate change has been <b>APPROVED BY KEN</b></td>
    </tr>
</table>
<br/><br/>
<input type = "submit" name = "add_record" id = "add_record" value = "Add Record" disabled></input>

<?php }?>

<br/><br/>
</form>
  <script src="/js/chosen/chosen.jquery.js" type="text/javascript"></script>
  <script type="text/javascript"> 
    var config = {
      '.chzn-select': {allow_single_deselect:true},
    }
    for (var selector in config) {
      $(selector).chosen(config[selector]);
    }
  </script>



</body>
</html>
